<?php

// $Id$

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/_sys/tcms_admin_page_w_grid_ua.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/grids/nomenclature_values/nomenclature_values_grid_ctrl.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/nomenclature/tcms_nomenclature_dbc.class.php');

class Nomenclature_Manage_WP extends TCMS_Admin_Page_W_Grid_UA {
	public function create_view($name = 'default') {
		$ret = new TCMS_Admin_Page_View($this, $name, 'modules/tangra_cms/pages/_nomenclature/');

		return $ret;
	}


	protected function init_transit_vars() {
		$this->add_transit_var('nom');
	}

	protected function create_grid_ctrl() {
		$tvm = $this->get_tvm();
		$nom_id = $this->get_transit_var('nom');
		$ret = new Nomenclature_Values_Grid_Ctrl('nomenclature_values', $tvm, Tangra_Parameter_Method::GET, $nom_id);

		return $ret;
	}


	protected function default_event($page_num = NULL) {
		$nom_id = $this->get_transit_var('nom');

		$dbc = $this->get_dbc();
		$nomenclature = new TCMS_Nomenclature_DBC();
		if (!$nomenclature->load_by_id($dbc, $nom_id)) {
			throw new Tangra_Module_Exception('Cannot load nomenclature with id = '.$nom_id);
		}
		$this->export('nom', $nomenclature);



		return parent::default_event($page_num);
	}
}

